package org.dt.common.sequence.spring.client;

import org.apache.commons.lang3.reflect.MethodUtils;
import org.dt.common.sequence.spring.client.AbstractSyncListCacheForSequenceClient;

import java.util.List;

/**
 * @author yujiadong
 * @create: 2019/02/28 16:48
 **/
public class MockSyncListCacheForSequenceClient extends AbstractSyncListCacheForSequenceClient<String> {

    public MockSyncListCacheForSequenceClient() {
        super(MethodUtils.getAccessibleMethod(SequenceSofaReference.class, "applyForPolicyNo", Integer.class), 1000, 0.5f);
    }

    @Override
    public Integer extractApplyNumber(Object[] args) {
        return (Integer) args[0];
    }

    @Override
    public Object[] buildTargetArguments(Integer actualNeeded, Object[] originArgs) {
        return new Object[]{actualNeeded};
    }


    @SuppressWarnings("unchecked")
    @Override
    public List<String> castOriginResult(Object result) {
        return (List<String>) result;
    }

    @Override
    public boolean support(Object bean, String beanName) {
        return beanName.equals("#");
    }
}
